package com.example.myblog1_0.mapper;

import com.example.myblog1_0.model.Comment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: xc
 * @Date: 2019/1/22 19:57
 * @Description:
 **/
@Mapper
@Repository
public interface CommentMapper {
    @Insert("insert into comment(articleID,replyID,userID,sendTime,content,osName,lastUserID) values(#{articleID},#{replyID},#{userID},#{sendTime},#{content},#{osName},#{lastUserID})")
    boolean saveComment(Comment comment);

    @Select("select * from comment where articleID = #{id} order by sendTime ")
    List<Comment> getCommentByID(@Param("id") String id);

    @Select("select * from comment where replyID = #{id} order by sendTime ")
    List<Comment> getReplyByCommentID(String id);

    @Select("select * from comment where id = #{id}  ")
    Comment getSingleCommentByID(String id);
}
